package config

import (
	"github.com/spf13/viper"
)

type Config struct {
	MySQLOptions *MySQLOptions `json:"mysql" mapstructure:"mysql"`
}

func New() *Config {
	//从配置文件中读取对应的配置
	v := viper.New()
	//文件的路径设置
	v.SetConfigFile("../conf/opts.yaml")
	if err := v.ReadInConfig(); err != nil {
		panic(err)
	}
	//全局变量
	var conf *Config
	if err := v.Unmarshal(&conf); err != nil {
		panic(err)
	}

	return conf
}
